<template>
    <el-menu class="el-menu-demo" mode="horizontal" @select="handleSelect">
        <el-menu-item index="1">
            <a href="/" target="_blank"><img src="" class="header-logo">logo </a>
        </el-menu-item>
        <el-menu-item index="4"><a href="/" target="_blank">首页</a></el-menu-item>
        <el-submenu index="3" style="float: right">
            <template slot="title">我的</template>
            <el-menu-item index="2-1">选项1</el-menu-item>
            <el-menu-item index="2-2">选项2</el-menu-item>
            <el-menu-item index="2-3" @click="logout">退出</el-menu-item>
        </el-submenu>
        <el-menu-item index="2" style="float: right">处理中心</el-menu-item>
    </el-menu>

</template>
<script>
    export default {
        methods: {
            logout() {
                this.$store.dispatch('user/logout');
                this.$router.push('/login');
            },
            handleSelect(key, keyPath) {
                console.log(key, keyPath);
            }
        },
        computed: {
            userName() {
                let userInfo = this.$store.state.user.userInfo;
                return !userInfo ? '' : userInfo.name;
            }
        }
    };
</script>
